<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateProduceStatementConfig extends AbstractMigration
{
    public function up()
    {

        $this->table('produce_statement_config', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '生成报表配置'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户id'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('month_time', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '月份时间戳'])
            ->addColumn('inside_cost', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '本月内部成本'])
            ->addColumn('outside_cost', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '本月外包成本'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间'])
            ->addColumn('created_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建人'])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间'])
            ->addColumn('updated_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新人'])
            ->addIndex(['project_id', 'month_time'], ['type' => 'normal', 'name' => 'idx_project_month_time'])
            ->save();
    }

    public function down()
    {
        $this->table('produce_statement_config')->drop()->save();
    }
}
